#include<iostream>
#include<ctime>
#include<cstdlib>
#include<queue>

using namespace std;

class BankSimulation
{
	int cashiers[4];
	int clients[15];
	queue<int> q;
	int clientsServiced;
	int maxLen;
	

public:

	BankSimulation()
	{
		for (int i = 0; i < 15; i++) 
		{
			clients[i] = 1 + (rand() % 480);
		}
		for (int i = 0; i < 4; i++)
		{
			cashiers[i] = 0;
		}
		clientsServiced = 0;
		maxLen = 0;
	}
	
	void putClient(int n)
	{
		q.push(n);
	}

	bool isCashierFree()
	{
		bool flag = false;
		for (int i = 0; i < 4; i++)
		{
			if (cashiers[i] == 0)
			{
				flag = true;
			}
		}
		return flag;
	}

	void removeClient(int cash)
	{
		cashiers[cash] = 0;
		clientsServiced++;
	}

	void fromQueueToCashier()
	{
		if (!q.empty())
		{
			for (int i = 0; i < 4; i++)
			{
				if (cashiers[i] == 0)
				{
					cashiers[i] = q.front();
					q.pop();
					return;
				}
			}
		}
	}


	void isClientInMinute(int min)
	{
		for (int i = 0; i < 15; i++)
		{
			if (clients[i] == min)
			{
				putClient(min); 
				fromQueueToCashier();
			}
		}
	}

	int getIndexOfCashiers(int num)
	{
		for (int i = 0; i < 4; i++)
		{
			if (cashiers[i] == num)
			{
				return i;
			}
		}
		return -1;
	}

	int getNumberFromIndex(int ind)
	{
		return cashiers[ind];
	}

	bool isQueueNotEmpty()
	{
		if (!q.empty()) 
		{
			return true;
		}
		return false;
	}

	int getClientsServiced()
	{
		return clientsServiced;
	}

	int queueLen(int min)
	{
		return q.size();
	}


};